﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Tipler.OzellikTipleri;
using Tipler.Enumlar;
using Tipler.DataSetler;
using IsKurallari.Sozlesme;
using Tipler.Siniflar;
using Tipler.RaporDataSetler;
using Microsoft.Reporting.WebForms;
using System.Data;

namespace IKYSWeb.Rapor
{
    [YetkiAttribute(EnumSayfaYetkileri.Herkes_Yetkili)]
    public partial class IsturChartRaporu : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {

                    SozlesmeIsKurali oSozlesme = new SozlesmeIsKurali();
                    FonksiyonSonuc<IsTurChart> oSonucSozlesme = oSozlesme.SozlesmeRaporGetir();
                    if (oSonucSozlesme.HataVarMi)
                        new Exception(oSonucSozlesme.Hata + oSonucSozlesme.ExMesaji);

                    DataSet dsRapor = new DataSet();
                    DataTable dtSozlesme = new DataTable();
                    dtSozlesme.TableName = "DsIsTur_DTIsTur";
                    dsRapor.Tables.Add(dtSozlesme);
                    dsRapor.Tables["DsIsTur_DTIsTur"].Merge(oSonucSozlesme.Sonuc.TBLIsTurChart);

                    rtpRaporum.Reset();
                    rtpRaporum.LocalReport.DataSources.Clear();
                    rtpRaporum.ProcessingMode = ProcessingMode.Local;
                    rtpRaporum.ShowToolBar = true;
                    rtpRaporum.LocalReport.DataSources.Clear();
                    rtpRaporum.LocalReport.EnableExternalImages = true;



                    rtpRaporum.LocalReport.ReportPath = Server.MapPath("/Rapor/IsturChartRapor.rdlc");

                    //Dataset bağlanmazsa hata veriyor Özlem
                    if (dsRapor != null)
                    {
                        foreach (DataTable dt in dsRapor.Tables)
                        {
                            rtpRaporum.LocalReport.DataSources.Add(new ReportDataSource(dt.TableName, dt));
                        }
                    }

                }
                catch (Exception exx)
                {
                    //rtpRaporum.LocalReport.GetParameters();
                    BasePage.EventLogYaz("RaporGoruntule.aspx de hata:" + exx.Message + " Rapor Adı :Sozlesme Sayıları ", System.Diagnostics.EventLogEntryType.Error);
                    return;
                }
            }
        }
    }
}